package org.longIt.springdata.repository;

import java.util.List;

import org.longIt.springdata.domain.Student;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

public interface StudentRepository extends JpaRepository<Student, Integer>{
	
	
	//JPQL    @Query注解 
	@Query(" select s from Student s where s.clazz.name = ?1 ")
	List<Student> queryClazzName(String clazzName);
	
    @Query(" select s from Student s where s.clazz.name = ?1 and s.sex = ?2 ")
	List<Student> querySexAndClazzName(String clazzName ,String sex);
	
	
    //因为删除属于DML语句隐藏需要使用注解，@Modifying声明，并且service层需要加上事务
    @Modifying
    @Query("delete from Student s where s.name = ?1 ")
	void removeByName(String name);
	
	

}
